package com.store.app.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.store.app.R;
import com.store.app.bean.SpecificationsBean;

import java.util.List;

/**
 * Created by Administrator on 2016/3/2.
 */
public class GridViewGuiGeAdapter extends BaseAdapter {
    private List<SpecificationsBean> specificationsBeanList;
    private Context context;
    private int clickTemp;
    public GridViewGuiGeAdapter(Context context, List<SpecificationsBean> specificationsBeanList) {
        this.context = context;
        this.specificationsBeanList = specificationsBeanList;
    }

    @Override
    public int getCount() {
        return specificationsBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return specificationsBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.gridview_item_guige, null);
        TextView tvContent = (TextView) convertView.findViewById(R.id.tv_content);
        tvContent.setText(specificationsBeanList.get(position).getDesc1());
        if (clickTemp == position) {
            tvContent.setTextColor(Color.RED);
            tvContent.setBackgroundResource(R.drawable.guige_select);
          } else {
            tvContent.setTextColor(Color.parseColor("#666666"));
            tvContent.setBackgroundResource(R.drawable.guige_default);
          }
        return convertView;
    }

    public void setSelection(int position){
          clickTemp = position;
      }

    public int getSelection(){
        return clickTemp;
    }
}
